#include <stdio.h>

struct Array {
		
	explicit Array(int const size) : my_size(size)
	{
		p=new int[my_size];	
	}

	Array(const Array& t)
	{
		p=new int[t.my_size];
		my_size=t.my_size;
		for (int i=0; i<my_size; ++i)
			set(i,t.get(i));
		
	}

    ~Array() 
	{
		delete[] p;
	}

	int get(int const index) const			
	{
		if (index < my_size)
			return p[index];	
		else 
		{
			printf("bad index \n");
			return 0;
		}
	}

	void set(int const index, int const value)
	{
		if (index < my_size)
			p[index]=value;	
		if (index == my_size-1)
			biggerfy();
	}


	Array& operator=(const Array& t)
	{
		Array *a=new Array(t.my_size);

		for(int i=0; i<t.my_size; ++i)
			(*a).set(i,t.get(i));			
		return *a;	
	}
	

private:


	int *p;
	int my_size;
		
	void biggerfy()
	{
		int* tmp=new int[my_size*2];
		for ( int i=0 ; i < my_size ; ++i )
			tmp[i]=p[i];
		delete[] p;
		my_size*=2;
		p=tmp;	
	}

};

int main()
{
	Array a (10);
	
	a.set(0,5); 
	a.set(7,9);
	
	printf("%d \n",a.get(0));
		
	return 0;
}
